<?php /** @var BootActiveForm $form */
$form = $this->beginWidget('bootstrap.widgets.BootActiveForm', array(
    'id'=>'horizontalForm',
    'type'=>'horizontal',
)); ?>

<fieldset>

    <legend>Tạo User mới</legend>

    <?php echo $form->textFieldRow($model, 'user_name',
    	array(
    	'hint'=>'Tên dùng để đăng nhập hệ thống')); ?>

    <?php echo $form->passwordFieldRow($model, 'password', array('class'=>'span3')); ?>

	<div class="control-group ">
		<label for="User_password" class="control-label required">Retype Password <span class="required">*</span></label>
		<div class="controls">
			<input type="password" maxlength="255" id="User_retype_password" name="User[retype_password]" class="span3">
		</div>
	</div>

	 <?php echo $form->radioButtonListRow($model, 'status', array(
	 	'Disable',
        'Active',
     )); ?>

     <?php echo $form->checkBoxListRow($model, 'roles', array(
        'ADMIN',
        'SUPER ADMIN',
    	)); ?>



</fieldset>

<div class="form-actions">
    <?php $this->widget('bootstrap.widgets.BootButton', array('buttonType'=>'submit', 'type'=>'primary', 'icon'=>'ok white', 'label'=>'Submit')); ?>
    <?php $this->widget('bootstrap.widgets.BootButton', array('buttonType'=>'reset', 'icon'=>'remove', 'label'=>'Reset')); ?>
</div>

<?php $this->endWidget(); ?>

<script type="text/javascript">
	$("form#horizontalForm").submit(function(){
		var password=$("#User_password").val();
		var retype_password=$("#User_retype_password").val();

		var roles=$(".checkbox input:checked").length;

		if(password!==retype_password) return false;

		if(roles==0){
			alert(" Bạn cần nhập quyền cho user mới");
			return false;
		}
	})
</script>